package fr.afcepf.atod21.data;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ResourceBundle;
import java.util.logging.Logger;

import javax.sql.DataSource;

/**
 * @author Stagiaire
 *
 */
public class Atod21DataSource implements DataSource{

    @Override
    public PrintWriter getLogWriter() throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter paramOut) throws SQLException {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void setLoginTimeout(int paramSeconds) throws SQLException {
        // TODO Auto-generated method stub
        
    }

    @Override
    public int getLoginTimeout() throws SQLException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public <T> T unwrap(Class<T> paramIface) throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public boolean isWrapperFor(Class<?> paramIface) throws SQLException {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public Connection getConnection() throws SQLException {
        
        Connection cnx = null;
        ResourceBundle resourceBundle = ResourceBundle.getBundle("fr.afcepf.atod21.ressources.db");
        try {
            Class.forName(resourceBundle.getString("jdbcDriver"));
            cnx = DriverManager.getConnection(resourceBundle.getString("url"), resourceBundle.getString("username"), resourceBundle.getString("password"));
        } catch (Exception e) {
            // TODO: handle exception
        }
        return cnx;
    }

    @Override
    public Connection getConnection(String paramUsername, String paramPassword)
            throws SQLException {
        // TODO Auto-generated method stub
        return null;
    }

}
